import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.util.*;


public class MyTerritoryPanel extends JPanel implements Observer, MouseListener{
	Observable Subject;
	private Territory myterritory;
	MyOrderPanel orderPanel;
	MainFrame.MyMapPanel mapPanel;
	
	public MyTerritoryPanel(Observable _Subject, MyOrderPanel _orderPanel, MainFrame.MyMapPanel _mapPanel){
		  Subject = _Subject;
		  orderPanel = _orderPanel;
		  mapPanel = _mapPanel;
		  myterritory = (Territory)Subject;
		   Subject.addObserver(this);
		   add(new JLabel(myterritory.getLocation()));
		   this.setBackground(myterritory.getOwner().getHue());
	       this.addMouseListener(this); 
	}
	
	public void update(Observable obs, Object arg){
		this.setBackground(myterritory.getOwner().getHue());
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		mapPanel.clearBorder();
		orderPanel.update(myterritory);
		this.setBorder(BorderFactory.createLineBorder (Color.black, 3));
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		
	}

	

}
